﻿/*
 * Created by SharpDevelop.
 * User: CeCi
 * Date: 27/03/2014
 * Time: 07:20 p.m.
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */
using System;
using System.Data.OleDb;
using System.Data;
using System.Windows.Forms;

namespace Gestión_UTN.util
{
	/// <summary>
	/// Description of Conexion.
	/// </summary>
	public class Conexion
	{
		public Conexion()
		{
			
		}
		
		static string CadenaConexion;
        static OleDbConnection Conex;
                
        public static OleDbConnection  conectarAccess()
        {
        	try {
                                
        			String ubicacion = Application.StartupPath + @"\Data\Original\Gestion.accdb";
                    CadenaConexion = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source="+ubicacion+";Persist Security Info=False";
                    Conex = new OleDbConnection(CadenaConexion);
                                
                 } catch (Exception ex) {
                		EscribirLog.escribirArchivo(ex.Message);
                        Conex = null;
                        MessageBox.Show("Error de Conexión!!","Error",MessageBoxButtons.OK,MessageBoxIcon.Error);
                   }
                        return Conex;
                }
        
        public static void desconectarAccess()
        {
           Conex.Close();
        }
	}
}
